home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / bstate.zip / BSTATEB.H < prev   
C/C++ Source or Header  |  1993-09-16  |  2KB  |  79 lines

  1. // bstateb.h : header file
  2. //
  3. // How to use CBStateButton
  4. //
  5. // 1. Create your dialog with an Ownerdraw pushbutton
  6. //
  7. // 2. Create bitmaps for each of your states (they must be the same size as
  8. //    the pushbutton for now)
  9. //
  10. // 3. Declare a CBStateButton in your dialog class
  11. //
  12. // In your InitDialog function
  13. //
  14. //        1. call the CBStateButton's AttachToButton(pushbuttonID, this) member
  15. //
  16. //        2. call the CBStateButton's AddState() function.  The first argument
  17. //           is the state value.  If you use your bitmap ID numbers as state
  18. //           values, this is all you need.  Otherwise, the second argument
  19. //           should be given as the bitmap ID number
  20. //
  21. //        3. call the CBStateButton's SetStateNumber() function any time you want to
  22. //           set the button's state
  23. //
  24. // Other routines:
  25. //
  26. //    GetStateNumber() returns the current state
  27. //
  28. // TODO: Add a way to set a background color (default to the upper left pixel of
  29. //       the bitmap) and make centering work
  30. // 
  31.  
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CBStateButton window
  34.  
  35. #define _CBSTATEMAX_    20
  36.  
  37. class CBStateButton : public CButton
  38. {
  39.     DECLARE_DYNAMIC(CBStateButton)
  40.     
  41. // Construction
  42. public:
  43.     CBStateButton(BOOL bCenter = FALSE, UINT nID = 0, CWnd *pParent = NULL);
  44.  
  45. // Attributes
  46. public:
  47.  
  48. // Operations
  49. public:
  50.     void AttachToButton(UINT, CWnd *);
  51.     void AddState(UINT, UINT);
  52.     void AddState(UINT);
  53.     // void AddState(UINT, CBitmap *);
  54.     void SetStateNumber(UINT);
  55.     int GetStateNumber(void);
  56.     
  57.     void Center(BOOL bCenter = TRUE);
  58.     
  59. private:
  60.     BOOL subclassed;
  61.     int curStateInd;
  62.     UINT states[_CBSTATEMAX_];
  63.     CBitmap *pictures[_CBSTATEMAX_];
  64.     UINT numStates;
  65.     BOOL center;
  66.     
  67.     void DoAddState(UINT, UINT);  
  68.  
  69. // Implementation
  70. public:
  71.     virtual ~CBStateButton();
  72.  
  73.     // Generated message map functions
  74. protected:
  75.     virtual void DrawItem(LPDRAWITEMSTRUCT lpDIS);
  76. };
  77.  
  78. /////////////////////////////////////////////////////////////////////////////
  79.